package com.bluejie.bluej.java.thread.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by bluej on 2018/1/28.
 */
public class ThreadPoolDemo {

    private static ThreadPoolDemo threadPool = new ThreadPoolDemo();

    public static void main(String[] args) {
        threadPool.handle();
    }

    private void handle(){
        ExecutorService executorService = Executors.newCachedThreadPool();

        for (int i = 0;i<10;i++){
            executorService.execute(new Task(100,i));
        }
    }
}



class Task implements Runnable{
    int a,b;

    public Task(int a,int b){
        this.a = a;
        this.b = b;
    }
    @Override
    public void run() {
        double c = 0.00 ;
        try {
            c = a/b;
        }catch (Exception e){
           // e.printStackTrace();
        }

        System.out.println(Thread.currentThread().getName()+"--"+c);
    }
}